// service-detail.js
Page({
  data: {
    id: null,
    title: '服务详情',
    spots: [],
    navHeight: 132
  },

  onLoad(query) {
    const { id = '', title = '服务详情' } = query || {}
    this.setData({ id, title })
    this.loadData(id)
  },

  onBackTap() {
    wx.navigateBack({
      fail: () => wx.reLaunch({ url: '/pages/index/index' })
    })
  },

  onNavHeightChange(e) {
    const { totalHeight } = e.detail || {}
    if (totalHeight) this.setData({ navHeight: totalHeight })
  },

  // 本地示例数据；后续可替换为接口请求
  loadData(id) {
    const map = {
      '1': [
        { id: '1-1', name: '黑麋峰红色教育基地', description: '在黑麋峰进行沉浸式红色教育参访路线。', cover: '/images/景点-3.jpg' },
        { id: '1-2', name: '黑麋峰党史教育馆', description: '党史学习、志愿服务与团队共建主题活动。', cover: '/images/景点-1.jpg' },
        { id: '1-3', name: '红色足迹步道', description: '串联重要纪念点的徒步线路。', cover: '/images/景点-2.jpg' },
        { id: '1-4', name: '党员活动中心', description: '主题党日与宣讲活动定制。', cover: '/images/景点-4.jpg' }
      ],
      '2': [
        { id: '2-1', name: '黑麋峰文化展馆', description: '本地文化与非遗展示之旅。', cover: '/images/景点-4.jpg' },
        { id: '2-2', name: '黑麋峰山景步道', description: '环线登高观景步道，山河壮美之旅。', cover: '/images/景点-2.jpg' },
        { id: '2-3', name: '工会职工之家', description: '职工关怀、培训与文体活动场地。', cover: '/images/民宿2.jpg' }
      ],
      '3': [
        { id: '3-1', name: '黑麋峰森林公园', description: '团队拓展、户外协作与破冰游戏。', cover: '/images/景点-3.jpg' },
        { id: '3-2', name: '山顶观景台', description: '观云海与落日的绝佳地点。', cover: '/images/景点-1.jpg' },
        { id: '3-3', name: '探险拓展营', description: '定向越野与绳索挑战。', cover: '/images/景点-2.jpg' }
      ],
      '4': [
        { id: '4-1', name: '黑麋峰研学线路A', description: '自然科普与人文历史结合的研学课程。', cover: '/images/景点-4.jpg' },
        { id: '4-2', name: '黑麋峰研学营地', description: '户外实践与课堂讲解结合，寓教于乐。', cover: '/images/民宿1.jpg' },
        { id: '4-3', name: '自然观察径', description: '昆虫、植物与地质的实地观察。', cover: '/images/景点-3.jpg' }
      ],
      '5': [
        { id: '5-1', name: '黑麋峰农事体验', description: '季节性农事体验活动，亲近土地与农作。', cover: '/images/ny.png' },
        { id: '5-2', name: '乡野采摘园', description: '时令果蔬采摘与田园餐桌。', cover: '/images/民宿1.jpg' },
        { id: '5-3', name: '农耕课堂', description: '传统农具与耕作方式体验。', cover: '/images/景点-4.jpg' }
      ],
      '6': [
        { id: '6-1', name: '黑麋峰游客中心', description: '咨询服务、线路指引与展陈体验。', cover: '/images/景点-2.jpg' },
        { id: '6-2', name: '游客服务驿站', description: '休憩、补给与应急服务。', cover: '/images/民宿2.jpg' }
      ],
      'default': [
        { id: 'd-1', name: '黑麋峰风景区', description: '精选图文介绍，现代极简卡片展示。', cover: '/images/景点-1.jpg' },
        { id: 'd-2', name: '黑麋峰环线', description: '环山慢行一日游建议路线。', cover: '/images/景点-2.jpg' }
      ]
    }
    const spots = map[id] || map['default']
    this.setData({ spots })
  },

  onPreview(e) {
    const idx = Number(e.currentTarget.dataset.index || 0)
    const urls = this.data.spots.map(s => s.cover)
    wx.previewImage({ current: urls[idx], urls })
  }
})
